package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IMediaListForPatrolMapForManagerView;
import com.cloudsigns.factorymanager2.engineering.bean.MediaBean;
import com.cloudsigns.factorymanager2.engineering.model.IMediaListForPatrolMapForManagerModel;
import com.cloudsigns.factorymanager2.engineering.model.MediaListForPatrolMapForManagerModel;

import java.util.List;

/** [ [巡查]获取巡查大区(机场)灯箱列表-给地图/表格用 ]
 * Created by tony on 2018/5/12.
 */

public class MediaListForPatrolMapForManagerPresenter {
    private IMediaListForPatrolMapForManagerView view;
    private IMediaListForPatrolMapForManagerModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public MediaListForPatrolMapForManagerPresenter(IMediaListForPatrolMapForManagerView view) {
        this.view = view;
        this.model = new MediaListForPatrolMapForManagerModel();
    }

    public void getPatrolMediaListForMap() {


        model.getPatrolMediaListForMap(view.getId(), new  MediaListForPatrolMapForManagerModel.OnPatrolMediaListForMapListener() {
            @Override
            public void getPatrolMediaListForMapSuccessed(final List<MediaBean> mediaBeanList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getPatrolMediaListForMapSuccessed(mediaBeanList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getPatrolMediaListForMapFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showFailedError(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
